﻿using System;
using System.Collections;
using System.Collections.Generic;
using Nop.Core.Domain.Common;
using Nop.Core.Domain.Discounts;
using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Stores;
using Nop.Core.Domain.Tax;
using Nop.Services.Orders;
using Nop.Services.Payments;

namespace Nop.Services.Stores
{
    public partial class StoreOrder
    {
        public StoreOrder()
        {
            this.ProcessPaymentResult = new ProcessPaymentResult();
            this.ProcessPaymentRequest = new ProcessPaymentRequest();
            this.ShoppingCarts = new Dictionary<Store, List<ShoppingCartItem>>();
        }

        /// <summary>
        /// Shopping cart item groups. The store id is the key. Values are the groupped shopping carts.
        /// </summary>
        public Dictionary<Store,  List<ShoppingCartItem>> ShoppingCarts { get; set; }

        /// <summary>
        /// Order group identifier
        /// </summary>
        public Guid OrderGroupId { get; set; }

        ///// <summary>
        ///// Results
        ///// </summary>
        //public IList<PlaceOrderResult> PlaceOrderResults { get; set; }

        /// <summary>
        /// Payment result
        /// </summary>
        public ProcessPaymentResult ProcessPaymentResult { get; set; }

        /// <summary>
        /// Payment request
        /// </summary>
        public ProcessPaymentRequest ProcessPaymentRequest { get; set; }

        /// <summary>
        /// Store payment info for stores
        /// </summary>
        public Hashtable StorePayments { get; set; }

        #region Nested 

        /// <summary>
        /// Store payment
        /// </summary>
        public class OrderInfo
        {
            /// <summary>
            /// Gets or sets the order subtotal (incl tax)
            /// </summary>
            public decimal OrderSubtotalInclTax { get; set; }

            /// <summary>
            /// Gets or sets the order subtotal (excl tax)
            /// </summary>
            public decimal OrderSubtotalExclTax { get; set; }

            /// <summary>
            /// Gets or sets the order subtotal discount (incl tax)
            /// </summary>
            public decimal OrderSubTotalDiscountInclTax { get; set; }

            /// <summary>
            /// Gets or sets the order subtotal discount (excl tax)
            /// </summary>
            public decimal OrderSubTotalDiscountExclTax { get; set; }

            /// <summary>
            /// Gets or sets the order shipping (incl tax)
            /// </summary>
            public decimal OrderShippingInclTax { get; set; }

            /// <summary>
            /// Gets or sets the order shipping (excl tax)
            /// </summary>
            public decimal OrderShippingExclTax { get; set; }

            /// <summary>
            /// Gets or sets the payment method additional fee (incl tax)
            /// </summary>
            public decimal PaymentMethodAdditionalFeeInclTax { get; set; }

            /// <summary>
            /// Gets or sets the payment method additional fee (excl tax)
            /// </summary>
            public decimal PaymentMethodAdditionalFeeExclTax { get; set; }

            /// <summary>
            /// Gets or sets the order tax
            /// </summary>
            public decimal OrderTax { get; set; }

            /// <summary>
            /// Gets or sets the order discount (applied to order total)
            /// </summary>
            public decimal OrderDiscount { get; set; }

            /// <summary>
            /// Gets or sets the order total
            /// </summary>
            public decimal OrderTotal { get; set; }

            /// <summary>
            /// Gets or set redeemRewardPoints
            /// </summary>
            public int RedeemedRewardPoints { get; set; }

            /// <summary>
            /// Gets or set redeemedRewardPointsAmount
            /// </summary>
            public decimal RedeemedRewardPointsAmount { get; set; }

            /// <summary>
            /// Vat number
            /// </summary>
            public string VatNumber { get; set; }

            /// <summary>
            /// Surcharges and taxes
            /// </summary>
            public List<Surcharge> Surcharges { get; set; }

            /// <summary>
            /// Requires shipping
            /// </summary>
            public bool RequiresShipping { get; set; }

            /// <summary>
            /// Shipping address
            /// </summary>
            public Address ShippingAddress { get; set; }

            /// <summary>
            /// ShippingMethodName
            /// </summary>
            public string ShippingMethodName { get; set; }

            /// <summary>
            /// ShippingRateComputationMethodSystemName
            /// </summary>
            public string ShippingRateComputationMethodSystemName { get; set; }

            public List<Discount> AppliedDiscounts { get; set; }

            public List<AppliedGiftCard> AppliedGiftCards { get; set; }
        }

        #endregion
    }
}
